<html>
<head>
    <script src="../../resources/js-test.js"></script>
    <script>
    function sendText(text) {
        document.execCommand('insertText', false, text);
    }

    function test() {
        var tf = document.getElementById('tf');

        var didFireOnChange = false;
        tf.onchange = function() {
          didFireOnChange = true;
        }

        if (window.testRunner) {
            testRunner.dumpAsText();
        }

        tf.focus();
        sendText('input value');
        tf.blur();

        debug('Should fire change event when type does not change.');
        shouldBeTrue(didFireOnChange.toString());

        didFireOnChange = false;
        tf.focus();
        sendText('new input value');
        tf.setAttribute('type', 'password');
        tf.blur();

        debug('Should *not* fire change event when type does not change.');
        shouldBeFalse(didFireOnChange.toString());
    }
    </script>
</head>
<body onload="test()">
    This tests that onchange is not fired after a form field's type changes.<br>
    <form name="fm">
        <input type="text" id="tf" />
    </form>
    <div id="console"></div>
</body>
</html>
